/*#include "ThreadPool.hpp"
#include "InetAddr.hpp"
#include <sys/socket.h>
#include <functional>
#include "Protocal.hpp"

#define BACKLOG 10

Parse parse;
// using task_t = std::function<void(int)>;   因为实际操作的函数是不传参的，所以这里的int也不用写
using task_t = std::function<void()>;

namespace Server
{
    using namespace ThreadPoolModule;
    class TcpServer
    {

    public:
        TcpServer(uint16_t port) : _port(port)
        {
            _listen_sockfd = ::socket(AF_INET, SOCK_STREAM, 0);
            InetAddr addr(_port);
            _addr = addr;
            ::bind(_listen_sockfd, _addr.GetSockaddr_In(), _addr.LenSockaddr_in());
            ::listen(_listen_sockfd, BACKLOG);
        }

        void HandlerReq(int sockfd)
        {
            std::string packge;
            char buffer[1024];
            while (true)
            {
                int n = ::recv(sockfd, buffer, sizeof(buffer) - 1, 0);
                if (n > 0)
                {
                    buffer[n] = 0;
                    packge += buffer;
                    std::string message = parse.Entry(packge);
                    if (message.empty())
                        continue;

                    int n = ::send(sockfd, message.c_str(), message.size(), 0);
                }
                if (n == 0)
                    break;
            }
            ::close(sockfd); // fd泄漏问题！
        }

        bool Start()
        {
            _isrunning = true;
            while (_isrunning)
            {
                socklen_t len = _addr.LenSockaddr_in();
                int sockfd = ::accept(_listen_sockfd, _addr.GetSockaddr_In(), &len);
                if (sockfd < 0)
                {
                    LOG(LogLevel::INFO) << "accept error";
                    continue;
                }
                task_t f = std::bind(&TcpServer::HandlerReq, this, sockfd);
                ThreadPool<task_t>::getInstance()->Equeue(f);
            }
        }


        ~TcpServer()
        {
        }

    private:
        int _listen_sockfd;
        uint16_t _port; // 作为服务器，固定端口，ip为INADDR_ANY
        InetAddr _addr;
        bool _isrunning;
    };
}*/